package com.bjsxt.wrapper;

public class TestInteger1 {

    public static void main(String[] args) {

        //1.自动装箱
        Integer i = 100;
        System.out.println(i);

        System.out.println("========");

        //2.自动拆箱
        int i1 = i;
        System.out.println(i1);

        System.out.println("========");

        //3.手动装箱
        Integer i2 = Integer.valueOf(200);
        System.out.println(i2);

        System.out.println("========");

        //4.手动拆箱
        int i3 = i2.intValue();
        System.out.println(i3);

        System.out.println("========");

        //==和equals区别
        Integer i4 = new Integer(100);
        Integer i5 = new Integer(100);
        System.out.println(i4 == i5);           //引用比较，不同对象，返回false
        System.out.println(i4.equals(i5));      //内容比较，相等，返回true

        System.out.println("========");

        //自动装箱不是执行new Integer()，而是执行Integer.valueOf()
        Integer i6 = 100;
        //Integer i6 = Integer.valueOf(100);
        Integer i7 = 100;                   //其他数字，返回false
        System.out.println(i6 == i7);       //[-128,127]区间的数字，返回true
        System.out.println(i6.equals(i7));

        System.out.println("========");

        Integer i8 = 1283;
        Integer i9 = 1283;
        System.out.println(i8 == i9);
        System.out.println(i8.equals(i9));

    }
}
